#!/usr/bin/python
# -*- coding: cp1250 -*-

import string, re, time

def toIso(inpTimestamp, timeStampType='dd.mm.yyyy'):
    '''
    >>> print toIso('2. 2. 7', timeStampType = 'dd.mm.yy')
    2007-02-02
    >>> print toIso('2. 2. 2007', timeStampType = 'd.m.yyyy')
    2007-02-02
    '''
    timeStampType=string.lower(timeStampType)
    date_s = re.sub('\s', '', inpTimestamp)
    if timeStampType in ('d.m.yy', 'dd.mm.yy'):
        # '6. 5. 4' -> 2004-05-06
        date_l = string.split(date_s, '.')
        date_s = string.join([  '20'+zf(date_l[2],2),
                                zf(date_l[1],2),
                                zf(date_l[0],2)
                             ], '-')
    if timeStampType in ('d.m.yyyy', 'dd.mm.yyyy'):
        # '2. 2. 2001' -> 2004-05-06
        date_l = string.split(date_s, '.')
        date_s = string.join([  date_l[2][:4],
                                zf(date_l[1],2),
                                zf(date_l[0],2)
                             ], '-')
    if timeStampType in ('mm/dd/yy', 'm/d/yy'):
        # '05/30/07' -> 2007-05-30
        date_l = string.split(date_s, '/')
        date_s = string.join([  '20'+date_l[2],
                                zf(date_l[0],2),
                                zf(date_l[1],2)
                             ], '-')
    return date_s

if __name__== '__main__':
    ''' '''
    pass
